You can use the GetHandleSize function and the SetHandleSize procedure to find out and change the logical size of a relocatable block, and you can use the GetPtrSize function and the SetPtrSize procedure to find out and change the logical size of a nonrelocatable block.
You can use the GetHandleSize function to find out the logical size of the relocatable block corresponding to a handle.
FUNCTION GetHandleSize (h: Handle): Size;
The GetHandleSize function returns the logical size, in bytes, of the relocatable block whose handle is h . In case of an error, GetHandleSize returns 0.
The registers on entry and exit for GetHandleSize are
Registers on exit |
|
---|---|
The trap dispatcher sets the condition codes before returning from a trap by testing the low-order word of register D0 with a TST.W instruction. Because the block size returned in D0 by _GetHandleSize is a full 32-bit long word, the word-length test sets the condition codes incorrectly in this case. To branch on the contents of D0, use your own TST.L instruction on return from the trap to test the full 32 bits of the register.
You can use the SetHandleSize procedure to change the logical size of the relocatable block corresponding to a handle.
PROCEDURE SetHandleSize (h: Handle; newSize: Size);
The SetHandleSize procedure attempts to change the logical size of the relocatable block whose handle is h . The new logical size is specified by newSize . SetHandleSize might need to move the relocatable block to obtain enough space for the resized block. Thus, for best results you should unlock a block before resizing it.
An attempt to increase the size of a locked block might fail, because of blocks above and below it that are either nonrelocatable or locked. You should be prepared for this possibility.
Because SetHandleSize allocates memory, you should not call it at interrupt time.
The registers on entry and exit for SetHandleSize are
Registers on exit |
|
---|---|
Instead of using the SetHandleSize procedure to set the size of a handle to 0, you can use the EmptyHandle procedure, described on EmptyHandle .
You can use the GetPtrSize function to find out the logical size of the nonrelocatable block corresponding to a pointer.
FUNCTION GetPtrSize (p: Ptr): Size;
The GetPtrSize function returns the logical size, in bytes, of the nonrelocatable block pointed to by p . In case of an error, GetPtrSize returns 0.
The registers on entry and exit for GetPtrSize are
Registers on exit |
|
---|---|
The trap dispatcher sets the condition codes before returning from a trap by testing the low-order word of register D0 with a TST.W instruction. Because the block size returned in D0 by _GetPtrSize is a full 32-bit long word, the word-length test sets the condition codes incorrectly in this case. To branch on the contents of D0, use your own TST.L instruction on return from the trap to test the full 32 bits of the register.
You can use the SetPtrSize procedure to change the logical size of the nonrelocatable block corresponding to a pointer.
PROCEDURE SetPtrSize (p: Ptr; newSize: Size);
The SetPtrSize procedure attempts to change the logical size of the nonrelocatable block pointed to by p . The new logical size is specified by newSize .
An attempt to increase the size of a nonrelocatable block might fail because of a block above it that is either nonrelocatable or locked. You should be prepared for this possibility.
Because SetPtrSize allocates memory, you should not call it at interrupt time.